//
//  SFLoginViewController.swift
//  SwiftForwardWayXu
//
//  Created by 郑程旭 on 2022/1/6.
//

import UIKit

class SFLoginViewController: SFBaseViewController, SFLoginViewDelegate {
    

    //Mark: - 生命周期
    override func viewDidLoad() {
        super.viewDidLoad()

        self.configSubviews()
        
    }
    
    //Mark: - 创建子视图
    func configSubviews() -> Void {
        self.view.addSubview(self.loginView)
        loginView.snp.makeConstraints { make in
            make.edges.equalTo(self.view).offset(0)
        }
    }
    
    lazy var loginView: SFLoginView = {
        let loginView = SFLoginView.init()
        loginView.delegate = self

        return loginView
    }()
    
    //MARK: - SFLoginViewDelegate
    //MARK: 设置用户地区
    func selectedArea(userRegion: Int) {
        SFNetCenter.center.configUserRegion(userRegion: userRegion)
    }

    //MARK: 登录
    func commitLogin(params: [String : Any]?, failure: Int) {
        guard failure == 0 else {
            //TODO: 条件不允许发起请求
            return
        }
        
        SFNetCenter.netCenterPostRequest(api: SFNetApi.apiSightPhoneLogin(params: params!)) { response in
            let data = response["data"]! as! NSDictionary
            print(data)
        } failure: {
            
        } complete: {
            
        }

    }
}




